package cn.zz.veggie.application.assembler;

import cn.hutool.core.util.StrUtil;
import cn.zz.comm.util.DateTimeUtil;
import cn.zz.veggie.model.domain.Purchase;
import cn.zz.veggie.model.domain.PurchaseItem;

/**
 * @author zhongq
 * @since 2024/6/8
 */
public class PurchaseAssembler {
	public static Purchase createPurchase(long statTime, int orderCount, int productCount) {
		Purchase purchase = new Purchase();
		purchase.setOrderCount(orderCount);
		purchase.setProductCount(productCount);
		purchase.setStatTime(statTime);
		purchase.setStatus(0);
		purchase.setRemark(StrUtil.EMPTY);
		purchase.setCreatedAt(DateTimeUtil.unixTime());
		purchase.setUpdatedAt(DateTimeUtil.unixTime());
		return purchase;
	}

	public static PurchaseItem createPurchaseItem(Integer productId, long statTime, int totalShipped) {
		PurchaseItem item = new PurchaseItem();
		item.setProductId(productId);
		item.setStatTime(statTime);
		item.setQuantity(totalShipped);
		item.setRemark(StrUtil.EMPTY);
		return item;
	}

	public static void updatePurchase(Purchase purchase, int orderCount, int productCount) {
		purchase.setOrderCount(orderCount);
		purchase.setProductCount(productCount);
	}
}